import request from '@/utils/request'
import { makeFormData } from '@/utils/util'

const api = {
  list: 'api/document_dir/list',
  infoList: 'api/documents/list',
  addDir: 'api/document_dir',
  info: 'api/documents',
  addDocument: 'api/documents',
  delDocument: 'api/documents'
}

export function getList (params = {}) {
  return request({
    url: api.list,
    method: 'get',
    params
  })
}

export function addDir (params = {}) {
  return request({
    url: api.addDir,
    method: 'post',
    params
  })
}

export function deleteDir (params = {}) {
  return request({
    url: api.addDir,
    method: 'delete',
    params
  })
}

export function getInfoList (params = {}) {
  return request({
    url: api.infoList,
    method: 'get',
    params
  })
}

export function addDocument (data = {}) {
  return request({
    url: api.addDocument,
    method: 'post',
    data: makeFormData(data)
  })
}

export function delDocument (params = {}) {
  return request({
    url: api.delDocument,
    method: 'delete',
    params
  })
}
